﻿using Stats.Distribution;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Stats.Test
{
    
    /// <summary>
    ///This is a test class for StandardNormalTest and is intended
    ///to contain all StandardNormalTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StandardNormalTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for z
        ///</summary>
        [TestMethod()]
        public void zTest()
        {
            double X = 68;
            double SampleMean = 64.5;
            double σ = 2.5;
            double expected = 1.4;
            double actual;
            actual = StandardNormal.z(X, SampleMean, σ);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for pValue
        ///</summary>
        [TestMethod()]
        public void pValueTest()
        {
            double zScore = 1.1;
            double expected = 0.1357; //http://www.statsoft.com/textbook/distribution-tables/#z
            double actual;
            actual = StandardNormal.pValue(zScore);
            Assert.AreEqual(expected, actual);

            zScore = 1.13;
            expected = 0.1292; //1 - .087076 http://controls.engin.umich.edu/wiki/index.php/Basic_statistics:_mean%2C_median%2C_average%2C_standard_deviation%2C_z-scores%2C_and_p-value#First_Method:_Z-Score
            
            actual = StandardNormal.pValue(zScore);
            Assert.AreEqual(expected, actual);
        }
    }
}
